#pragma once
#include "Markup.h"

#define XML_EXT ""

#define SAFE_DELETE(ptr) \
	if (ptr) { delete (ptr); (ptr) = NULL; }

class CSnbWriter
{
public:
	CSnbWriter();
	~CSnbWriter();
public:
	BOOL AddBook(CString fileName, int nChapters = 0);
	BOOL AddChapter(CString sTitle, const char* sContent,
		const char* sImg, CString& sSnbc, BOOL bHideTitle = FALSE);
	BOOL AddToChapter(CString sSnbc, const char* sContent, const char* sImg, int w = 0, int h = 0);
	BOOL WriteBookSnbf(CString sVersion, CString sName, CString sAuthor,
		CString sLanguage, CString sRights, CString sPublisher,
		CString sGenerator, CString sCreated, CString sAbstract,
		CString sCover);
	static CString NormalizeString(const char* pString);
	BOOL FlushSnbc();
private:
	CMarkup m_writerBookSnbf;
	CMarkup m_writerTocSnbf;
	CMarkup* m_pWriterSnbc;
	CString m_fileName;
	CString m_sTocSnbf;
	CString m_sCurSnbc;
	int m_nCurChapter;
};